<!DOCTYPE html>
<html class="writer-html5" lang="en" data-content_root="../../">
<head>
  <meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />

  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>(&lt;&lt;)/2 &mdash; The Logtalk Handbook v3.93.0-b01 documentation</title>
      <link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=d75fae25" />
      <link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=19f00094" />
      <link rel="stylesheet" type="text/css" href="../../_static/css/custom.css?v=396eccfe" />

  
  <!--[if lt IE 9]>
    <script src="../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
        <script src="../../_static/jquery.js?v=5d32c60e"></script>
        <script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
        <script src="../../_static/documentation_options.js?v=c8100655"></script>
        <script src="../../_static/doctools.js?v=9a2dae69"></script>
        <script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
    <script src="../../_static/js/theme.js"></script>
    <!-- begin favicon -->
    <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
    <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
    <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />
    <link rel="manifest" href="/site.webmanifest" />
    <link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5" />
    <meta name="msapplication-TileColor" content="#355b95" />
    <meta name="theme-color" content="#ffffff" />
    <!-- end favicon -->
    
    <link rel="index" title="Index" href="../../genindex.html" />
    <link rel="search" title="Search" href="../../search.html" />
    <link rel="next" title="Directives" href="../directives/index.html" />
    <link rel="prev" title="Context switching calls" href="context_switching_calls.html" />
   
</head>

<body class="wy-body-for-nav"> 
  <div class="wy-grid-for-nav">
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >

          
          
          <a href="../../index.html" class="icon icon-home">
            The Logtalk Handbook
              <img src="../../_static/logtalk.gif" class="logo" alt="Logo"/>
          </a>
              <div class="version">
                3.93.0
              </div>
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>
        </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
    
              <p class="caption" role="heading"><span class="caption-text">Contents</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../userman/index.html">User Manual</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../index.html">Reference Manual</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../grammar.html">Grammar</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="index.html">Control constructs</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="message_sending.html">Message sending</a></li>
<li class="toctree-l3"><a class="reference internal" href="message_delegation.html">Message delegation</a></li>
<li class="toctree-l3"><a class="reference internal" href="super_calls.html">Calling imported and inherited predicates</a></li>
<li class="toctree-l3"><a class="reference internal" href="call_in_this.html">Calling predicates in <em>this</em></a></li>
<li class="toctree-l3"><a class="reference internal" href="external_calls.html">Calling external predicates</a></li>
<li class="toctree-l3 current"><a class="reference internal" href="context_switching_calls.html">Context switching calls</a><ul class="current">
<li class="toctree-l4 current"><a class="current reference internal" href="#"><code class="docutils literal notranslate"><span class="pre">(&lt;&lt;)/2</span></code></a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../directives/index.html">Directives</a></li>
<li class="toctree-l2"><a class="reference internal" href="../predicates/index.html">Built-in predicates</a></li>
<li class="toctree-l2"><a class="reference internal" href="../methods/index.html">Built-in methods</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../tutorial/index.html">Tutorial</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../faq/index.html">FAQ</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../devtools/index.html">Developer Tools</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../libraries/index.html">Libraries</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../ports/index.html">Ports</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../contributions/index.html">Contributions</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../glossary.html">Glossary</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../bibliography.html">Bibliography</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../genindex.html">Index</a></li>
</ul>

    <p class="caption"><span class="caption-text">External Contents</span></p>
    <ul>
    <li class="toctree-l1"><a class="reference internal" href="../../../apis/index.html">APIs</a></li>
    <li class="toctree-l1"><a class="reference internal" href="https://logtalk.org">Logtalk website</a></li>
    <li class="toctree-l1"><a class="reference internal" href="https://github.com/LogtalkDotOrg/logtalk3">GitHub repo</a></li>
    </ul>
  
        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../index.html">The Logtalk Handbook</a>
      </nav>

      <div class="wy-nav-content">
        <div class="rst-content">
          <div role="navigation" aria-label="Page navigation">
  <ul class="wy-breadcrumbs">
      <li><a href="../../index.html" class="icon icon-home" aria-label="Home"></a></li>
          <li class="breadcrumb-item"><a href="../index.html">Reference Manual</a></li>
          <li class="breadcrumb-item"><a href="index.html">Control constructs</a></li>
          <li class="breadcrumb-item"><a href="context_switching_calls.html">Context switching calls</a></li>
      <li class="breadcrumb-item active"><code class="docutils literal notranslate"><span class="pre">(&lt;&lt;)/2</span></code></li>
      <li class="wy-breadcrumbs-aside">
              <a href="https://github.com/LogtalkDotOrg/logtalk3/blob/master/docs/handbook/sources/refman/control/context_switch_2.rst" class="fa fa-github"> Edit on GitHub</a>
      </li>
  </ul>
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
             
  <p class="align-right"><strong>control construct</strong></p>
<section id="control-context-switch-2">
<span id="index-0"></span><span id="id1"></span><h1><code class="docutils literal notranslate"><span class="pre">(&lt;&lt;)/2</span></code><a class="headerlink" href="#control-context-switch-2" title="Link to this heading"></a></h1>
<section id="description">
<h2>Description<a class="headerlink" href="#description" title="Link to this heading"></a></h2>
<div class="highlight-logtalk notranslate"><div class="highlight"><pre><span></span><span class="nv">Object</span><span class="o">&lt;&lt;</span><span class="nv">Goal</span>
<span class="k">{</span><span class="nv">Proxy</span><span class="k">}</span><span class="o">&lt;&lt;</span><span class="nv">Goal</span>
</pre></div>
</div>
<p>Debugging control construct. Calls a goal within the context of the
specified object. The goal is called with the following execution context:</p>
<ul class="simple">
<li><p><a class="reference internal" href="../../glossary.html#term-sender"><span class="xref std std-term">sender</span></a>, <a class="reference internal" href="../../glossary.html#term-this"><span class="xref std std-term">this</span></a>, and <a class="reference internal" href="../../glossary.html#term-self"><span class="xref std std-term">self</span></a> values set to the object</p></li>
<li><p>empty meta-call context</p></li>
<li><p>empty coinduction stack</p></li>
</ul>
<p>The goal may need to be written between parenthesis to avoid parsing errors
due to operator conflicts. This control construct should only be used for
debugging or for writing unit tests. This control construct can only be used
for objects compiled with the
<a class="reference internal" href="../../userman/programming.html#flag-context-switching-calls"><span class="std std-ref">context_switching_calls</span></a> compiler
flag set to <code class="docutils literal notranslate"><span class="pre">allow</span></code>. Set this compiler flag to <code class="docutils literal notranslate"><span class="pre">deny</span></code> to disable
this control construct and thus prevent using it to break encapsulation
when deploying applications.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">{Proxy}&lt;&lt;Goal</span></code> syntax allows simplified access to
<a class="reference internal" href="../../glossary.html#term-parametric-object-proxy"><span class="xref std std-term">parametric object proxies</span></a>.
Its operational semantics is equivalent to the goal conjunction
<code class="docutils literal notranslate"><span class="pre">(call(Proxy),</span> <span class="pre">Proxy&lt;&lt;Goal)</span></code>. I.e. <code class="docutils literal notranslate"><span class="pre">Proxy</span></code> is proved within the
context of the pseudo-object <a class="reference internal" href="../../userman/objects.html#objects-user"><span class="std std-ref">user</span></a> and, if successful,
the goal term is used as a parametric object identifier. Exceptions thrown
when proving <code class="docutils literal notranslate"><span class="pre">Proxy</span></code> are handled by the <code class="docutils literal notranslate"><span class="pre">(&lt;&lt;)/2</span></code> control construct.
This syntax construct supports backtracking over the <code class="docutils literal notranslate"><span class="pre">{Proxy}</span></code> goal.</p>
<p>Caveat: although the goal argument is fully compiled before calling,
some necessary information for the second compiler pass may not be
available at runtime.</p>
</section>
<section id="modes-and-number-of-proofs">
<h2>Modes and number of proofs<a class="headerlink" href="#modes-and-number-of-proofs" title="Link to this heading"></a></h2>
<div class="highlight-logtalk notranslate"><div class="highlight"><pre><span></span><span class="o">+</span>object_identifier<span class="o">&lt;&lt;+</span>callable <span class="o">-</span> zero_or_more
<span class="k">{</span><span class="o">+</span>object_identifier<span class="k">}</span><span class="o">&lt;&lt;+</span>callable <span class="o">-</span> zero_or_more
</pre></div>
</div>
</section>
<section id="errors">
<h2>Errors<a class="headerlink" href="#errors" title="Link to this heading"></a></h2>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">Object</span></code> is a variable:</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">instantiation_error</span></code></div>
</div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Object</span></code> is neither a variable nor a valid object identifier:</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">type_error(object_identifier,</span> <span class="pre">Object)</span></code></div>
</div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Object</span></code> does not contain a local definition for the Goal predicate:</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">existence_error(procedure,</span> <span class="pre">Goal)</span></code></div>
</div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Object</span></code> does not exist:</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">existence_error(object,</span> <span class="pre">Object)</span></code></div>
</div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Object</span></code> was created/compiled with support for context-switching calls turned off:</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">permission_error(access,</span> <span class="pre">database,</span> <span class="pre">Goal)</span></code></div>
<div class="line"><br /></div>
</div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Proxy</span></code> is a variable:</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">instantiation_error</span></code></div>
</div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Proxy</span></code> is neither a variable nor an object identifier:</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">type_error(object_identifier,</span> <span class="pre">Proxy)</span></code></div>
</div>
<div class="line">The predicate <code class="docutils literal notranslate"><span class="pre">Proxy</span></code> does not exist in the <code class="docutils literal notranslate"><span class="pre">user</span></code> pseudo-object:</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">existence_error(procedure,</span> <span class="pre">ProxyFunctor/ProxyArity)</span></code></div>
<div class="line"><br /></div>
</div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Goal</span></code> is a variable:</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">instantiation_error</span></code></div>
</div>
<div class="line"><code class="docutils literal notranslate"><span class="pre">Goal</span></code> is neither a variable nor a callable term:</div>
<div class="line-block">
<div class="line"><code class="docutils literal notranslate"><span class="pre">type_error(callable,</span> <span class="pre">Goal)</span></code></div>
</div>
</div>
</section>
<section id="examples">
<h2>Examples<a class="headerlink" href="#examples" title="Link to this heading"></a></h2>
<div class="highlight-logtalk notranslate"><div class="highlight"><pre><span></span><span class="c">% call the member/2 predicate in the</span>
<span class="c">% context of the &quot;list&quot; object:</span>
test(member) <span class="o">:-</span>
    list <span class="o">&lt;&lt;</span> member(<span class="m">1</span>, [<span class="m">1</span>]).
</pre></div>
</div>
</section>
</section>


           </div>
          </div>
          <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
        <a href="context_switching_calls.html" class="btn btn-neutral float-left" title="Context switching calls" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
        <a href="../directives/index.html" class="btn btn-neutral float-right" title="Directives" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>&#169; Copyright 1998-2025, Paulo Moura.</p>
  </div>

  Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
    <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
    provided by <a href="https://readthedocs.org">Read the Docs</a>.
   

</footer>
        </div>
      </div>
    </section>
  </div>
  <script>
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script> 

</body>
</html>